home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ShareWare OnLine 2
/
ShareWare OnLine Volume 2 (CMS Software)(1993).iso
/
comm1
/
dnload30.zip
/
DNLOADPR.WAS
< prev
next >
Wrap
Text File
|
1993-04-22
|
16KB
|
560 lines
;****Download Pro 3.0 (c) 1993, Michael Lee ***************************
;**** Log On Procedures (c) 1993, Gregg Hommel *
;**Globals**************************************************************
string filespec,zipath,qwk_work,result,qfile,to_call ;*
string newfile,qwkfile,saved_file ;*
string prowin_path=$PWTASKPATH ;*
string prompt_str,start_time,stop_time,name ;*
string delay_time,delay_date,time_is,current_time,current_date ;*
string M1,M2,C1,B5,B6,zip_to ;*
integer watchfor,lang=0,graph=0,status3,setjump=0,mxdial,nowdial ;*
;***********************************************************************
proc main
integer status2,status1
call checkit_out
;******************
;The Main Procedure will display the .QWK files for you to choose from.
;It also let you select the files to download, save to a file and start
;the log_on procedure.
; Calls unzip_qwk, show_saved, get_newfiles, dnload, save_file, delay_call
;******************
strfmt S7 "%s\dnload.ini" prowin_path
profilerd S7 "PATH" "storage" C1
strfmt qwkfile "%s\newfiles.dat" C1
strfmt newfile "%s\newfiles.txt" C1 ;prowin_path
profilerd S7 "PATH" "qwkpath" filespec
strfmt M1 "%s\save.fil" C1 ;prowin_path
strfmt M2 "%s\save.bak" C1 ;prowin_path
setjmp 0 setjump
loop_back:
dialogbox 64 62 148 139 2 "Download Pro V. 2.00"
pushbutton 50 75 40 14 "&OK" normal
dirlistbox 20 19 100 49 filespec single qfile
text 23 6 94 8 left "Please Select .QWK Packet"
groupbox 22 96 106 33 "Batch Option" shadow
pushbutton 32 108 88 15 "View Saved File" normal
enddialog
status2=$DIALOG
while status2!=10 || status1!=11 ;loop until the eather OK or
if status2==10 ;Download Saved pushbutton is choosen.
call unzip_qwk
exitwhile
endif
if status2==11
isfile M1
if success
call view_file
else
usermsg "There are no Saved Files to view!"
goto loop_back
endif
endif
status2=$DIALOG
endwhile
;************************
;This dialog will display the New Files from the selected .QWK
;packet. This is where you select the files you would like to
;download.
;************************
dialogbox 28 17 304 184 2 "Download File Dialog"
text 92 10 108 8 left "Please Select Files to Download!"
flistbox 14 25 274 133 qwkfile multiple newfile
pushbutton 92 164 40 14 "&OK" normal
pushbutton 165 164 40 14 "&CANCEL" cancel
enddialog
status3=$DIALOG
while status3!=10
status3=$DIALOG
if status3==1
exit
endif
endwhile
call get_newfiles
;**************************
;"File Options" lets you Download the file now, save the selected
;filenames to a file or delay the download for a time you choose.
;**************************
dialogbox 84 49 103 94 2 "File Options"
pushbutton 20 5 61 22 "&Download Now" normal default
pushbutton 20 34 61 22 "&Save to File!" normal
pushbutton 20 64 60 21 "D&elay Download" normal
enddialog
;line 50
status1=$DIALOG
while status1!=10 || status1!=11 || status1!=12
if status1==10
call dnload
exitwhile
endif
if status1==11
call save_file
endif
if status1==12
call delay_call
exitwhile
endif
status1=$DIALOG
endwhile
endproc
;******
;This proc unzips the .QWK packet.
;******
proc unzip_qwk
profilerd S7 "PATH" "zippath" zipath
profilerd S7 "PATH" "qwkwk" qwk_work
strfmt S1 "%s\pkunzip %s control.dat newfiles.dat -o %s" zipath qfile qwk_work
dos S1 HIDDEN i0 ;using the STRFMT varible S1. This line unzips the control.dat
while istask i0 ;file and newfiles.dat file.
endwhile
endproc
;*******
;This proc is used to process the results of the Download File Dialog
;Box. It will strips the filename from the line of text and saves the
;filename in the Results.txt file. The Newfiles.txt file is the resulting
;strings from flistbox in the Download File Dialog Box.
;*******
proc get_newfiles
integer idx
strfmt S6 "%s\newfiles.txt" C1 ;prowin_path
fopen 3 S6 READ TEXT
if not success
usermsg "Could not find newfiles.txt!"
endif
strfmt S8 "%s\results.txt" C1 ;prowin_path
fopen 1 S8 CREATE TEXT
fclose 1
fopen 1 S8 READWRITE TEXT
while not feof 3
fgets 3 S4
strfind S4 " " idx ;looks for a space and places its results in IDX.
if idx<0 ;I had to add this to prevent an error if theres
goto jump ;no End Of File marker in the file.
endif
substr result S4 0 idx ;strips the filename from the string
fputs 1 result ;writes the results to Results.txt
endwhile
jump:
fclose 1
fclose 3
endproc
;**********
;This proc finds the BBS to call and calls log-on with this info.
;**********
proc dnload
string a1 ;,to_be
integer index
;this section opens control.dat file of the .QWK and reads the BBS name
;the .QWK came from.
strfmt S9 "%s\control.dat" C1 ;qwk_work
fopen 4 S9 READ TEXT
fgets 4 a1
fgets 4 a1
fgets 4 a1
fgets 4 a1
fgets 4 to_call ;reads the 5th line from Control.dat to find
strfind to_call "," index ;the BBS name this .QWK came from.
index++
strdelete to_call 0 index ;to_call now contains the BBS to call.
fclose 4
call log_on
endproc
;****The Save_file proc looks in your Prowin directory to see if
; Results.txt has been saved before. If it was, it renames save.fil
;to save.bak and then renames Results.txt to save.fil.
;*****
proc save_file
string B1,B2
strfmt B1 "%s\SAVE.FIL" C1 ;formats save.fil with your prowin path
strfmt B2 "%s\SAVE.BAK" C1 ;formats save.bak with your prowin path
isfile B1
if success
rename B1 B2 ;renames SAVE.FIL to SAVE.BAK
rename S8 B1 ;renames results.txt to SAVE.FIL
else
rename S8 B1 ;same as above
endif
exit
endproc
;********
;This procedure gets the BBS number from the Board.ini file and dials
;the number.
;********
proc log_on
string bbs_num1,bbs_num2,bbs_num3
integer max_retry
when target 0 "?" call get_prompt
set modem autobaud on
strfmt B5 "%s\board.ini" prowin_path
strfmt B6 "%s\dnload.ini" prowin_path
profilerd B5 to_call "bbs_number1" bbs_num1
profilerd B5 to_call "bbs_number2" bbs_num2
profilerd B5 to_call "bbs_number3" bbs_num3
profilerd B6 "DIAL" "max_session" mxdial
profilerd B6 "DIAL" "max_retry" max_retry
set dialdir access max_retry
nowdial=0
while 1
if mxdial>nowdial
;usermsg "num3=%s" bbs_num3
;usermsg "num1=%s num2=%s" bbs_num1 bbs_num2
if not NULLSTR bbs_num1
dialnumber bbs_num1
while $DIALING
endwhile
if $CARRIER
exitwhile
endif
endif
if not NULLSTR bbs_num2
;usermsg "dialing num2"
dialnumber bbs_num2
while $DIALING
endwhile
if $CARRIER
exitwhile
endif
endif
if not NULLSTR bbs_num3
;usermsg "dialing num3"
dialnumber bbs_num3
while $DIALING
endwhile
if $CARRIER
exitwhile
endif
endif
nowdial++
endif
endwhile
watchfor=1
while watchfor
endwhile
clearwhen target 0
call get_files
endproc
;********
;This procedure handles all the prompts from a PcBoard BBS and sends the
;proper responce to each prompt.
;Thanks to Gregg Hommel this proc is available.
;CALLS chk_prompt
;********
proc get_prompt
string user,pasword
termgets $ROW 0 prompt_str $COL
if chk_prompt("Command")
watchfor = 0
elseif chk_prompt("Enter)=yes?") || chk_prompt("More?") || chk_prompt ("Enter = Yes?")
transmit "N^M"
elseif chk_prompt("=no change?") && lang == 0
transmit "^M"
lang++
elseif chk_prompt("Enter)=no?") || chk_prompt("continue?") || chk_prompt("=none?") || chk_prompt("Enter = No?")
if chk_prompt("graphics") || chk_prompt("Color?") && graph == 0
transmit "N Q NS^M"
graph++
else
transmit "^M"
endif
elseif chk_prompt("Password (Dots")
profilerd B5 to_call "PASSWORD" pasword
transmit pasword
transmit "^M"
elseif chk_prompt("name?")
profilerd B5 to_call "USERID" user
profilerd B5 to_call "PASSWORD" pasword
transmit USER
transmit " "
transmit PASWORD
transmit "^M"
elseif chk_prompt("new user?") || chk_prompt("new caller?")
transmit "r^M"
endif
endproc
func chk_prompt:integer
strparm chk_out
strfind prompt_str chk_out
return FOUND
endfunc
;*********
;This procedure is used to open the results.txt file and send the filenames
;to the BBS. It also gets the starting and stop time of the download (used
;in create_log).
;CALLS process_file and create_log
;*********
proc get_files
set dialdir access $DIALENTRY
set cdinxfer yes
fopen 0 S8 READ TEXT ;opens newfiles.txt
if not success
errormsg "Can't open Results.Txt file!"
endif
transmit "d^M"
while not feof 0 ;loops until the End of file marker is reached.
fgets 0 S0
call process_file
endwhile
transmit "g^M"
fclose 0
time start_time ;get starting time of download
strcpy name to_call
pause 15
while $CARRIER ;status==1 ;loop until download is over and BBS Disconnects
pause 1
endwhile
time stop_time ;get stop time of download
call create_log
endproc
;**************
; Process_file accually sends the files to the BBS, using the system
;varible S0.
;**************
proc process_file
waitfor "none?"
transmit S0
transmit "^M"
endproc
;************
; Create_log creates the log file. It is stored in the Path
;"C:\prowin\log\log.txt". (You may need to change the path statement).
;It also provides the formating of the Log file and inserts the
;information in the proper place.
;***********
proc create_log
string dat,B3
found_log:
strfmt B3 "%s\log.txt" C1 ;prowin_path
chdir C1
findfirst B3 ;checks to see if log.txt exists.
if not FOUND ;If not found, it creates it.
usermsg "Log.Txt will now be created!"
fopen 0 B3 CREATE TEXT
fclose 0
goto found_log ;loops to start of this proc.
else
fopen 0 B3 READWRITE TEXT
strfmt S4 "System Name: %s" name
dat=$DATE
strfmt S1 "Date: %s" dat
strfmt S2 "Start Time: %s" start_time
strfmt S3 "Stop Time: %s" stop_time
fseek 0 0 2 ;\
fputs 0 " " ; \
fputs 0 S4 ; \
fputs 0 S1 ; Write the log the the file.
fputs 0 S2 ; /
fputs 0 S3 ;/
fputs 0 "Downloaded Files:"
fopen 1 S8 READ TEXT ;opens results.txt
while not feof 1 ;write the filenames to the log.
fgets 1 S5
fputs 0 S5
endwhile
fclose 1
endif
fclose 0 ;closes log.txt
exit
endproc
;********
;This procedure handles the delay of the download. It displays the
;Delayed Download Dialog box along with the updated time every second.
;It will display until the execution time has been reached.
;********
proc delay_call
integer status,status4
delay_date=$DATE
current_date=$DATE
current_time=$TIME24
dialogbox 82 56 208 110 2 "Delay Execution"
text 8 16 48 8 left "Current Time:"
vtext 53 16 33 8 left current_time
text 105 16 49 8 left "Current Date:"
vtext 155 16 35 10 left current_date
groupbox 6 5 194 27 "Current Time & Date" shadow
editbox 137 41 35 12 delay_time 9
text 33 43 102 8 left "Enter Start Time (HH:MM:SS):"
text 33 60 105 8 left "Enter New Date (MM/DD/YY):"
editbox 137 59 35 12 delay_date 9
pushbutton 48 83 40 15 "&OK" normal default
pushbutton 113 83 40 15 "&Cancel" cancel
enddialog
status=$DIALOG
while status!=10 || status!=1
status=$DIALOG
if status==1
exit
endif
if status==10
exitwhile
endif
endwhile
destroydlg
dialogbox 106 70 137 83 2 "Delayed Download"
vtext 74 9 44 8 left time_is
text 26 9 48 8 left "Current Time:"
text 26 24 56 8 left "Execution Time:"
vtext 87 25 44 10 left delay_time
text 26 38 57 8 left "Execution Date:"
vtext 87 38 45 8 left delay_date
pushbutton 49 56 40 14 "E&xit" normal
enddialog
status4=$DIALOG
while 1 ;loops until the execution time has been reached.
status4=$DIALOG
current_time=$TIME24
current_date=$DATE
if status4==10 ;if exit is selected, Exit.
destroydlg
exitwhile
endif
strcmp current_date delay_Date ;compare current and delay times.
if $strcmp == 0
strcmp current_time delay_Time ;if date and time match, exit loop.
if $strcmp == 0
exitwhile
destroydlg
endif
endif
if $strcmp!=0
updatedlg 64
endif
time_is=current_time
endwhile
destroydlg
call dnload
endproc
;*********************
;"View File" will display the Files that you have saved (Save.fil and/or save.bak)
;If you select "View Next" from the Dialog, it first checks to see if
;SAVE.BAK is there. If not, it will display a message "No more files to view!",
;If SAVE.BAK is on the disk, it will display that file. It will switch
;between these two files (for each click of "View Next") until you eather
;Choose "Download Files" or "CANCEL". "Download Files" will proceed with
;the download of the files Displayed. "CANCEL" will go back to the main
;Dialog "Download Pro".
proc view_file
integer status9
strcpy saved_file M1 ;copy Save.fil (M1) to saved_file.
loop_save:
dialogbox 72 34 196 149 2 "Saved File Viewer"
text 13 12 28 8 left "Viewing:"
vtext 44 12 65 8 left saved_file
pushbutton 136 9 40 14 "View Next" normal
ftext 34 32 134 73 saved_file
pushbutton 60 110 79 13 "Download Files" normal
pushbutton 61 129 77 13 "&CANCEL" cancel
enddialog
status9=$DIALOG
while status9!=1 ;loop unless CANCEL is selected.
status9=$DIALOG
if status9==11
isfile S8 ;looks for results.txt.
if success ;if found
delfile S8 ;deleted it.
endif
copyfile saved_file S8 ;copies selected files to results.txt.
strcmp saved_file M1 ;compares saved_file to SAVE.FIL
if success ;if the same, proceed.
delfile M1 ;delete SAVE.FIL
isfile M2 ;looks for SAVE.BAK
if success
rename M2 M1 ;rename SAVE.BAK to SAVE.FIL
;delfile M2
endif
else
delfile M2
endif
call dnload
endif
if status9==10
strcmp saved_file M1
if success
isfile M2
if success
strcpy saved_file M2
else
usermsg "No more Files to view!"
goto loop_save
endif
else
strcpy saved_file M1
endif
goto loop_save
endif
endwhile
if status9==1
longjmp 0 setjump ;if CANCEL is selected, jump to main
endif ;Dialog.
endproc
proc checkit_out
integer test1=0,test2=0,test3=0
string miss1,miss2,miss3
strfmt B5 "%s\board.ini" prowin_path
strfmt B6 "%s\dnload.ini" prowin_path
strfmt S7 "%s\dnload.ini" prowin_path
profilerd S7 "PATH" "storage" C1
profilerd S7 "PATH" "zip_to" zip_to
profilerd S7 "PATH" "qwkwk" qwk_work
if not chdir C1
usermsg "no C1"
test1=1
endif
if not chdir zip_to
usermsg "no zip_to"
test2=1
endif
if not chdir qwk_work
usermsg "No qwk_work"
test3=1
endif
if test1!=0 || test2!=0 || test3!=0
if test1!=0
miss1="Download Pro Storage Path:"
endif
if test2!=0
miss2="Unzip To Path"
endif
if test3!=0
miss3="Mail Packet Working Path"
endif
errormsg "The Following Paths are not setup:%s %s %s" miss1 miss2 miss3
exit
endif
endproc